home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Exchange / Distribution List / DistList.bas next >
Encoding:
BASIC Source File  |  1999-02-03  |  3.4 KB  |  95 lines

  1. Attribute VB_Name = "Module1"
  2. Sub Main()
  3. Dim sec As New ADsSecurity
  4. Dim sd As IADsSecurityDescriptor
  5. Dim dacl As IADsAccessControlList
  6. Dim ace As New AccessControlEntry
  7.  
  8. Const RIGHT_DS_MODIFY_USER_ATT = &H2
  9. Const RIGHT_MAIL_SEND_AS = &H8
  10. Const RIGHT_MAIL_RECEIVE_AS = &H10
  11.  
  12.  
  13.  
  14.  
  15.  
  16. '-------------------------------------------------------
  17. '-----CREATING A DISTRIBUTION LIST  ----------------------
  18. '--------------------------------------------------------
  19.  
  20. '---- Server, Org and Site information
  21. server = "andyhar04:390"
  22. org = "Microsoft"
  23. Site = "WINDOWS2000"
  24.  
  25. '--- Distribution List -----
  26. strDisplayname = "Distributed System PM"
  27. strAlias = "dpm"
  28. strSMTPAddr = "dpm@arcadiabay.com"
  29.  
  30. '--- Build Recipient container's adsPath that looks like this: LDAP://myserver/CN=Recipients, OU=Site, O=Org
  31. ADsPath = "LDAP://" + server
  32. ADsPath = ADsPath + "/cn=Recipients,OU="
  33. ADsPath = ADsPath + Site
  34. ADsPath = ADsPath + ",O="
  35. ADsPath = ADsPath + org
  36.  
  37.  
  38. Set objCont = GetObject(ADsPath)
  39. 'Create a new DL
  40. Set objNewDL = objCont.Create("groupOfNames", "cn=" & strAlias)
  41.   
  42. 'Set the DL props
  43. objNewDL.Put "cn", CStr(strDisplayname)
  44. objNewDL.Put "uid", CStr(strAlias)
  45. objNewDL.Put "mail", CStr(strSMTPAddr)
  46. objNewDL.SetInfo
  47.    
  48.    
  49.    
  50. '---------------------------------------------------------------
  51. '--- ADDING MEMBERS TO A DISTRIBUTION LIST
  52. '-----------------------------------------------------------------
  53. Set dl = GetObject("LDAP://excsrv11/cn=dpm,cn=Recipients,ou=REDMOND,o=Microsoft")
  54. dl.Add "LDAP://excsrv11/cn=jsmith,cn=Recipients,ou=REDMOND,o=Microsoft"
  55. dl.Add "LDAP://excsrv11/cn=andyhar,cn=Recipients,ou=REDMOND,o=Microsoft"
  56.  
  57. '------------------------------------------------------------------
  58. ' -- ENUMERATE MEMBERS IN A DISTRIBUTION LIST
  59. '-----------------------------------------------------------------
  60. Set dl = GetObject("LDAP://excsrv11/cn=dpm,cn=Recipients,ou=REDMOND,o=Microsoft")
  61. For Each member In dl.Members
  62.    Debug.Print member.Name & " (" & member.Class & ")"
  63. Next
  64.  
  65. '----------------------------------------------------------------------
  66. '--- REMOVING MEMBERS IN A DISTRIBUTION LIST
  67. '-----------------------------------------------------------------------
  68. Set dl = GetObject("LDAP://excsrv11/cn=dpm,cn=Recipients,ou=REDMOND,o=Microsoft")
  69. dl.Remove "LDAP://excsrv11/cn=jsmith,cn=Recipients,ou=REDMOND,o=Microsoft"
  70.  
  71.  
  72.  
  73. '-------------------------------------------------------------------------------------
  74. '--- SET THE OWNER OF THE DISTRIBUTION LIST
  75. '------------------------------------------------------------------------------------
  76. Set dl = GetObject("LDAP://excsrv11/cn=dpm,cn=Recipients,ou=REDMOND,o=Microsoft")
  77. dl.Put "Owner", "cn=andyhar,cn=Recipients,ou=REDMOND,o=Microsoft"
  78. dl.SetInfo
  79.  
  80. '------------------------------------------------------------------------
  81. '-- SET PERMISSION ON THE OWNER TO MODIFY AND SEND AS/RECEIVE ------------
  82. '--- REQUIRED THE ADSI RESOURCE TOOL KIT INSTALL (IADsSecurity)-----------------------
  83. '-------------------------------------------------------------------------
  84. Set sd = sec.GetSecurityDescriptor("LDAP://excsrv11/cn=dpm,cn=Recipients,ou=REDMOND,o=Microsoft")
  85. Set dacl = sd.DiscretionaryAcl
  86.  
  87. ace.AccessMask = RIGHT_DS_MODIFY_USER_ATT Or RIGHT_MAIL_SEND_AS Or RIGHT_MAIL_RECEIVE_AS
  88. ace.Trustee = "REDMOND\andyhar"
  89. dacl.AddAce ace
  90. sd.DiscretionaryAcl = dacl
  91. sec.SetSecurityDescriptor sd
  92.  
  93.  
  94. End Sub
  95.